#include "driver/gpio.h"

#define BSP_USB_MODE_SEL      (GPIO_NUM_18) // Select Host (high level) or Device (low level, default) mode

esp_err_t bsp_usb_mode_select_device(void)
{
    // Make sure the pin is configured
    const gpio_config_t led_io_config = {
        .pin_bit_mask = BIT64(BSP_USB_MODE_SEL),
        .mode = GPIO_MODE_OUTPUT,
        .pull_up_en = GPIO_PULLUP_DISABLE,
        .pull_down_en = GPIO_PULLDOWN_DISABLE,
        .intr_type = GPIO_INTR_DISABLE
    };
    gpio_config(&led_io_config);
    gpio_set_level(BSP_USB_MODE_SEL, 0);
    return ESP_OK;
}